#include "address.h"
#include "log.h"

#include <map>

johnsonli::Logger::ptr g_logger = LOG_ROOT();

void test()
{
    std::vector<johnsonli::Address::ptr> address;

    LOG_INFO(g_logger) << "begin";

    bool v = johnsonli::Address::Lookup(address, "www.baidu.com:80");
    LOG_INFO(g_logger) << "end";
    if(!v)
    {
        LOG_ERROR(g_logger) << "lookup fail";
        return;     
    }

    for(size_t i = 0; i<address.size(); ++i)
    {
        LOG_INFO(g_logger) << i << "-" << address[i]->toString();
    }
}

void test_iface()
{
    std::multimap<std::string, std::pair<johnsonli::Address::ptr, uint32_t>> results;

    bool v = johnsonli::Address::GetInterfaceAddresses(results,AF_INET6);
    if(!v)
    {
        LOG_ERROR(g_logger) << "GetInterfaceAddresses fail";
        return;
    }

    for(auto&i : results)
    {
        LOG_INFO(g_logger) << i.first << "-" << i.second.first->toString() << " " <<i.second.second;
    }
}


void test_ipaddr()
{
    //auto addr = johnsonli::IPAddress::Create("0.0.0.0", 8020);
}

int main()
{
    //test_ipaddr();
    return 0;
}
